package logic

import (
	"context"
	"short-vid-joy/shortrpc/shortrpc"

	"short-vid-joy/api/internal/svc"
	"short-vid-joy/api/internal/types"

	"github.com/zeromicro/go-zero/core/logx"
)

type DelVideoLogic struct {
	logx.Logger
	ctx    context.Context
	svcCtx *svc.ServiceContext
}

func NewDelVideoLogic(ctx context.Context, svcCtx *svc.ServiceContext) *DelVideoLogic {
	return &DelVideoLogic{
		Logger: logx.WithContext(ctx),
		ctx:    ctx,
		svcCtx: svcCtx,
	}
}

func (l *DelVideoLogic) DelVideo(req *types.DelVideoRequest) (resp *types.Response, err error) {
	// todo: add your logic here and delete this line

	date, err := l.svcCtx.ShortRpc.DelVideo(l.ctx, &shortrpc.DelVideoRequest{
		UserId:  req.UserId,
		VideoId: req.VideoId,
	})
	if err != nil {
		return &types.Response{
			Message: err.Error(),
			Code:    500,
			Data:    nil,
		}, nil
	}

	return &types.Response{
		Message: "视频删除成功",
		Code:    200,
		Data:    date,
	}, nil
}
